This invention relates generally to digital signal processing and more particularly to a method and system for generating a trigonometric function.
Determination of the value of sine and cosine of an arbitrary angle is required in a number of Digital Signal Processing (DSP) applications. A frequently occurring application is the Direct Digital Synthesizer (DDS), which generates an output frequency that is proportional to an input frequency control value. The output signal is a multi-bit word that updates at the sample rate to represent a sine-wave at the programmed frequency. Many DDS implementations simultaneously output quadrature (sine and cosine) signals for use in complex tuning applications. A number of implementations also require high resolution phase input and sine/cosine output signal representations to allow processing of signals with a wide dynamic range.
The standard method of determining sine and cosine functions at a high sample rate uses a look-up table (LUT). If the input is a certain number of bits, P, in length, then there are 2P different inputs possible. So an LUT for a P-bit input would require 2P rows, one row for each possible input. If the output is a certain number of bits, S, in length, then the LUT would require a column S bits wide. Therefore, an LUT for a P-bit input and an S-bit output requires 2Pxc3x97S bits of memory.
For example, a typical LUT provides P=8 bits of phase input resolution and S=8 bits of sine/cosine output resolution. This LUT would contain 28=256 locations of eight bits each for a total of 2,048 memory bits. However, some applications need a higher resolution LUT, which requires an exponentially higher number of memory bits. For example, doubling the number of the input bits and output bits from 8 to 16 increases the memory requirements from 2,048 bits to 1,048,576 bits. Simultaneous generation of 16-bit sine and cosine output values for a single 16-bit phase input value would require 2,097,152 bits of memory. Thus, small-memory devices, such as field-programmable gate arrays, application-specific integrated circuits, and others, are unable to provide this resolution with look-up tables that require more memory than is available.
In accordance with the present invention, a method and system for generating a trigonometric function are provided that substantially eliminate or reduce disadvantages and problems associated with previously developed systems and methods. In particular, the present invention, with relatively small memory requirements, generates a high-resolution trigonometric function.
In one embodiment of the present invention, an input angle is received and is automatically separated into a first component angle and a second component angle. A sine value for the input angle is automatically determined based upon the first and second component angles. A cosine value for the input angle is automatically determined based upon the first and second component angles. The trigonometric function is automatically generated based upon the sine and cosine values for the input angle.
More specifically, in accordance with a particular embodiment of the present invention, a sine value for the first component angle is determined by retrieving from a first look-up table of value corresponding to the first component angle. A cosine value for the first component angle is determined by retrieving from a second look-up table a value corresponding to the first component angle. A sine value for the second component angle is calculated based upon a linear approximation. A first intermediate value is generated based upon the sine value for the first component angle and the sine value for the second component angle. A second intermediate value is generated based upon the cosine value for the first component angle and the sine value for the second component angle. The cosine value for the input angle is determined based upon the first intermediate value and the cosine value for the first component angle. The sine value for the input angle is determined based upon the second intermediate value and the sine value for the first component angle.
Technical advantages of the present invention include providing an improved method and system for generating a trigonometric function. In particular, a high-resolution trigonometric function may be generated by separating an input angle into at least two component angles. For at least one of the component angles, a sine value is calculated and a cosine value is set at a constant. As a result, memory requirements are reduced. Accordingly, the improved method and system may be implemented in small memory devices, such as FPGAs, ASICs, and the like, and may also be implemented more efficiently in large memory devices. In addition, the reduced memory requirements provided by the present invention result in a corresponding reduction in the cost of producing a trigonometric function generator.